/*
 *
 *   This file is part of jSevenBar. Copyright 2011 Alex Volodko
 *
 *   Licensed under the Apache License, Version 2.0 (the "License");
 *   you may not use this file except in compliance with the License.
 *   You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 *   Unless required by applicable law or agreed to in writing, software
 *   distributed under the License is distributed on an "AS IS" BASIS,
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *   See the License for the specific language governing permissions and
 *   limitations under the License.
 *
 */
package de.xhelp.jsevenbar.core;


/**
 * @author Alex Volodko
 *
 */
public class TaskbarEntry {

	private final int hwnd;
	
	private static native int activateTab(int hwnd);
	private static native int setActiveAlt(int hwnd);
	private static native int addTab(int hwnd);
	private static native int deleteTab(int hwnd);
	
	private boolean visible;
	/**
	 * Getter
	 * @return the visible
	 */
	public boolean isVisible() {
		return visible;
	}
	/**
	 * Setter
	 * @param visible the visible to set
	 */
	public void setVisible(boolean visible) {
		this.visible = visible;
		int result;
		if (visible) {
			result = addTab(hwnd);
		} else {
			result = deleteTab(hwnd);
		}
		if (result!=JSevenBar.S_OK) {
			throw new IllegalStateException("Return code: "+result);
		}
	}
	
	public TaskbarEntry(int hwnd) {
		this.hwnd = hwnd;
		visible = true;
	}
	
	public void activate() {
		int result = activateTab(hwnd);
		if (result!=JSevenBar.S_OK) {
			throw new IllegalStateException("Return code: "+result);
		}
	}
	
}
